package designpattern.staticfactorypattern;

/**
 * @author hubb
 * @Date 2019/3/28 23:46
 */
public class LoginManager {
    public static Login factory(String loginType) {

        if ("password".equals(loginType)) {

            return new PasswordLogin();

        } else if ("passcode".equals(loginType)) {

            return new DomainLogin();

        } else {
            /**
             * 这里抛出一个自定义异常会更恰当
             */
            throw new RuntimeException("没有找到登录类型");
        }
    }
}
